//// 公共下拉菜单方法        
//// 创建Ajax.Request对象，发起一个Ajax请求
//// url 是 Action 路径
//// selectid1 点击的下拉菜单id名称
//// selectid2 动态生成的下拉菜单id名称
//// attribute 在Action中frombean属性名称
//var publicSelectId = "";
function newajax(url,selectid1,selectid2) {
	var select = document.getElementById(selectid1);
	publicSelectId = selectid2;
	url = url;
	//var url='LoginAction.do?id=123'; 
	//alert(url);
	if(select.value != ""){
		//var myAjax = new Ajax.Request(url,{method:'post',asynchronous: false,onComplete: showResponse} ); 
		jQuery.ajax({
			url:url,
			data:{'attribute':select.value},
			type:'post',
			async:false,
			success:function(response){
				response = response.replace("\n","");
				var obj=eval("("+response+")");
				addOption(obj.strb,selectid2);
			}
		});
	}else{//清空下拉
		delSelect(selectid2);
	}
}

function newajax1(url,selectid1,selectid2,selectid3) {
	var select1 = document.getElementById(selectid1);
	var select2 = document.getElementById(selectid2);
	publicSelectId = selectid3;
	url = url;
	//var url='LoginAction.do?id=123'; 
	//alert(url);
	if(select.value != ""){
		//var myAjax = new Ajax.Request(url,{method:'post',asynchronous: false,onComplete: showResponse} ); 
		jQuery.ajax({
			url:url,
			data:{'attribute':select1.value,'attribute2':select2.value},
			type:'post',
			async:false,
			success:function(response){
				var obj=eval("("+response+")");
				addOption(obj.strb,selectid3);
			}
		});
	}else{//清空下拉
		delSelect(selectid3);
	}
}

//
////返回的函数
//function showResponse(originalRequest) {
//	alert(originalRequest.responseText);
//	var obj=eval("("+originalRequest.responseText+")");
//	alert("+++++++++++++++++"+obj.strb);
//	var asd = originalRequest.responseText;
//	addOption(asd,publicSelectId);
//
//}
//
////动态添加下拉选项
function addOption(str,selectid){
	
	var select = document.getElementById(selectid);
	//清空下拉
	delSelect(selectid);
	
	var option = str.split(';');
	for(var i=0; i<option.length; i++){
		var temp = option[i].split(':');
		select.options[i]  = new Option(temp[1], temp[0]);
	}
	publicSelectId = "";
}

//删除单一下拉菜单所有内容
function delSelect(selectid){
	if(null!=document.getElementById(selectid)){
		var select = document.getElementById(selectid);
		var del = select.length+1;
		if(del>1){
			for(var i=del;i>0;i--)
			{
				select[i-1] = null;
			}
		}
		select.options[0]  = new Option("","");
	}
	
}

function newLab1(url,selectid1,lab1,lab2) {
	var select = document.getElementById(selectid1);
	url = url;
	//var url='LoginAction.do?id=123'; 
	//alert(url);
	if(select.value != ""){
		//var myAjax = new Ajax.Request(url,{method:'post',asynchronous: false,onComplete: showResponse} ); 
		jQuery.ajax({
			url:url,
			data:{'attribute':select.value},
			type:'post',
			async:false,
			success:function(response){
				var obj=eval("("+response+")");
				addLab1(obj.strb,lab1,lab2);
			}
		});
	}else{//清空下拉
		delLab(lab1);
		delLab(lab2);
	}
}
function addLab1(str,lab1,lab2){
	var lab1 = document.getElementById(lab1);
	var lab2 = document.getElementById(lab2);
	//清空
	delLab(lab1);
	delLab(lab2);
	lab1.innerText = str.split(',')[0];
	lab2.innerText = str.split(',')[1];
}
function delLab(lab){
	if(null!=document.getElementById(lab)){
		var lab = document.getElementById(lab);
		lab.innerText = "";
	}
}